<template>
	<view class="bigbox">
		<!-- 控制高度 -->
		<view bar style="background: #fff;">

		</view>
		<!-- UserImage user name -->
		<view class="userinfoBox">
			<view class="userTitleImgae">
				<image class="" src="@/static/userimage.jpg">

				</image>
			</view>
			<view class="">
				<view class="" w800>
					{{ state.userinfo.username ||"立即登录"}}

				</view>
				<view class="PhoneNumber">
					<!-- phoneNumber -->
					{{ state.userinfo.phoneNumber || ""}}
				</view>
			</view>
		</view>
		<!-- 余额 -->
		<view class="MoneyBox">
			<view class="balanceBox">
				<view class="">
					{{ toThousands(state.balance?.Paintbalance) || "0"}}
				</view>
				<view class="">
					次
				</view>
			</view>
			<view class="IntegralBox">
				<view class="">
					<view class="">
						{{ toThousands(state.balance?.Chatbalance) || "0"}}
					</view>
					<view class="">
						积分
					</view>
				</view>
				<view class="">
					<view class="">
						充值次数
					</view>
				</view>
			</view>
		</view>
		<!-- 菜单 -->
		<view class="menuBox" v-for="item, index in state.menu" @tap="item.tap()" :key="index">
			<view class="">

			</view>
			<view class="" f12>
				{{ item.name }}
			</view>
			<view class="">
				<image class="" src="@/static/right.png" mode="aspectFit|aspectFill|widthFix" lazy-load="false" binderror=""
					bindload="">

				</image>
			</view>
		</view>
		<!-- <view class="LoginButton" @tap="navLogin">
			退出登录
		</view> -->
	</view>
</template>

<script setup>
import { reactive, ref, onMounted } from "vue"
import { onShow, onLoad } from "@dcloudio/uni-app"
import { userStore } from "@/store/user.js"
import { toThousands } from "@/util/Number.js"
onMounted(() => {

})
onLoad(() => {
	state.userinfo = uni.getStorageSync("userinfo") 
	// 获取余额
    
})
onShow(() => {
	Getbalance()
})
const userState = userStore()
const state = reactive({
	menu: [
		{
			name: "充值记录",
			icon: "none",
			url: "",
			tap: () => {
				console.log(123);
			}
		},
		{
			name: "关于我们",
			icon: "none",
			url: "",
			tap: () => {
				console.log(123);
			}
		},
		{
			name: "退出登录",
			icon: "none",
			url: "",
			tap: () => {
				navLogin()
			}
		}
	],
	useinfo: {
	},
	balance: {}
})
const navLogin = () => {
	uni.setStorageSync("token", "")
	uni.redirectTo({
		url: "/pages/login/login"
	})
}
const Getbalance = () => {
	let data = {
		Account: uni.getStorageSync("userinfo").Account
	}

	userState.Getbalance(data).then(res => {
		console.log(res);
		state.balance = res.data
	}).catch(err => { 
		console.log(err);
	})
}
</script>

<style lang="scss" scoped>
.bigbox {
	height: 100%;
	width: 100%;
}

.userinfoBox {
	height: 105px;
	display: flex;
	// background: red;
	align-items: center;
	margin: 0 15px;
	box-sizing: border-box;
}

.userTitleImgae {
	width: 55px;
	height: 55px;
	border-radius: 55px;
	background: rgb(221, 221, 244);
	margin-right: 15px;
	overflow: hidden;

	>image {
		width: 100%;
		height: 100%;
	}
}

.LoginButton {
	// width: 100%;
	// background: #266EFE;
	// display: flex;
	// align-items: center;
	// margin-top: 35px;
	// justify-content: center;
	// padding: 10px 0;
	// color: #fff;
	// border-radius: 25px;
	// margin-top: 70%;
}

.PhoneNumber {
	font-size: 14px;
	color: #999;
	margin-top: 3px;
}

.MoneyBox {
	height: 15%;
	min-height: 140px;
	background: #6AA6F4;
	margin: 0 15px 25px;
	border-radius: 10px;
	box-sizing: border-box;
	padding: 20px 15px;
	color: #fff;

}

.balanceBox {
	>view:nth-child(1) {
		font-size: 22px;
		font-weight: 800;
	}

	>view:nth-child(2) {
		font-size: 12px;
		color: #fff;
		margin-top: 3px;
	}
}

.IntegralBox {
	display: flex;
	padding-right: 25px;
	margin-top: 15px;

	>view:nth-child(2) {
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: flex-end;

		>view {
			padding: 8px 15px;
			background: #fff;
			font-size: 14px;
			font-weight: 600;
			border-radius: 15px;
			color: #5187EB;
			font-weight: 600;
		}
	}

	>view:nth-child(1) {

		// margin-top: 10px;
		>view:nth-child(1) {
			font-size: 14px;
			;
			font-weight: 800;
		}

		>view:nth-child(2) {
			font-size: 12px;
			;

		}
	}
}

.menuBox {
	margin: 0 15px;
	padding: 10px 0;
	display: flex;
	box-sizing: border-box;
	align-items: center;

	>view:nth-child(1) {
		width: 25px;
		height: 25px;
		border: 1px solid #ccc;
		margin-right: 15px;
	}

	>view:nth-child(2) {
		flex: 1;
	}

	>view:nth-child(3) {
		height: 25px;
		width: 25px;

		>image {
			width: 100%;
			height: 100%;
		}
	}
}
</style>
